//
//  LennoverComputerBuilder.m
//  Wsj2017_构建者模式_1
//
//  Created by macOS on 2017/4/21.
//  Copyright © 2017年 macOS. All rights reserved.
//

#import "LennoverComputerBuilder.h"

#import "LennoverComputer.h"

//这种链式调用  是典型的build构建的应用(不同的参数列表 最终产生的对象不同)
@interface LennoverComputerBuilder ()

@property(nonatomic) id<IComputer> computer;

@end


@implementation LennoverComputerBuilder

//持有电脑的引用

- (instancetype)init
{
    self = [super init];
    if (self) {
        _computer =  [LennoverComputer new];
    }
    return self;
}


- (id<IComputerBuilder>)builderCPU:(NSString *)cpu{
   
    [_computer cpu:cpu];
    
    return self;

}

- (id<IComputerBuilder>)builderDisplay:(NSString *)display{
    
    [_computer display:display];
    return  self;
}


- (id<IComputerBuilder>)builderMainboard:(NSString *)mainboard{
  
    [_computer mainboard:mainboard];
    return self;
}


- (id<IComputerBuilder>)builderOs:(NSString *)os{
    
    [_computer os:os];
  return  self;
}

- (id<IComputer>)builder{
   
    
    NSLog(@"电脑构建处理.....");
    sleep(3);
    NSLog(@"电脑构建处理完成!!!!");
    return  _computer;
}



@end
